

PM_FUNC_PUBLIC_ATTRIB plugin_natives()
{
	//Placing this here because this may be the first forward called
	pokemod_advdebug_file();

	pokemod_funcstart_debug( "plugin_natives" );

	register_native( "PokeModRegisterFunction", "NativeRegisterFunction" );
	register_native( "PokeModExecuteScript", "NativeExecuteScript" );

	pokemod_funcend_debug( "plugin_natives" );
}

PM_FUNC_PUBLIC_ATTRIB NativeRegisterFunction( Int:iPlugin, Int:iParams )
{
	if ( iParams != 1 )
		return 0;

	new String:szFuncName[ NAME_LEN ];
	get_string( 1, szFuncName, charsmax(szFuncName) );

	if ( g_iFunctionTrie == Invalid_Trie )
	{
		log_amx( "PokeModRegisterFunction( ^"%s^" ) called too soon.", szFuncName );
		return 0;
	}

	TrieSetCell( g_iFunctionTrie, szFuncName, SCRIPTFUNC_CUSTOM );

	return 1;
}

PM_FUNC_PUBLIC_ATTRIB NativeExecuteScript( Int:iPlugin, Int:iParams )
{
	if ( iParams < 2 || g_iState == PM_DISABLED )
		return 0;

	new Int:id = get_param( 1 );

	new String:szScriptLine[ 128 ];
	vdformat( szScriptLine, charsmax(szScriptLine), 2, 3 );

	if ( g_iFunctionTrie == Invalid_Trie )
	{
		log_amx( "PokeModExecuteScript( %d, ^"%s^" ) called too soon.", id, szScriptLine );
		return 0;
	}

	return ScriptDoLine( id, szScriptLine );
}
